package cn.com.xy.sms.sdk.db.entity;

import android.content.ContentValues;
import android.database.Cursor;
/**
 * Created by admin on 2016/11/24.
 */

public class UrlPreviewItem {
    private long id;
    private String url;
    private String data;
    private long date;

    public UrlPreviewItem() {
        this.date = System.currentTimeMillis();
    }

    public UrlPreviewItem setData(String data) {
        this.data = data;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public UrlPreviewItem setDate(long date) {
        this.date = date;
        return this;
    }

    public String getData() {
        return data;
    }

    public long getDate() {
        return this.date;
    }

    public UrlPreviewItem(Cursor cursor) {
        this.id = Long.parseLong(cursor.getString(cursor.getColumnIndex(UrlPreviewManager.KEY_ID)));
        this.data = cursor.getString(cursor.getColumnIndex(UrlPreviewManager.KEY_DATA));
        this.url = cursor.getString(cursor.getColumnIndex(UrlPreviewManager.KEY_URL));
        this.date = Long.parseLong(cursor.getString(cursor.getColumnIndex(UrlPreviewManager.KEY_DATE)));
    }

    public ContentValues getContentValues() {
        ContentValues values = new ContentValues();

        values.put(UrlPreviewManager.KEY_URL, this.url);
        values.put(UrlPreviewManager.KEY_DATE, this.date);
        values.put(UrlPreviewManager.KEY_DATA, this.data);

        return values;
    }
}
